/**
 * 
 */
package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.MessageDAOInterface;
import org.cuatrovientos.erp.model.Message;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author eneko_lana
 * This class implements MessageBOInterface
 */
public class MessageBO implements MessageBOInterface{
	// Get log4j logger
		private static final Logger logger = Logger.getLogger(MessageBO.class);
		
		@Autowired
	    private MessageDAOInterface MessageDAO;
		
	/**
	 * @param int id
	 * @return Message Message
	 * This method returns a Message selected by it's id
	 */
	@Override
	public Message selectById(int id) {
		logger.info("selectById: " + id);
		return MessageDAO.selectById(id);
	}
	
	/**
	 * @return All the countries we have in the database
	 */
	@Override
	public List<Message> selectAll() {
		logger.info("selectAll: ");
		return MessageDAO.selectAll();
	}
	
	/**
	 * @return The number of countries we have in the database
	 */
	@Override
	public List<Message> search(String title) {
		logger.info("search : " + title);
		return MessageDAO.search(title);
	}
	
	/**
	 * @param int id
	 * This method deletes the Message selected by id
	 */
	@Override
	public void deleteById(int id) {
		logger.info("delete by: " + id + " id");
		MessageDAO.deleteById(id);
	}
	
	/**
	 * @param Message Message
	 * This method insert a Message in the database passed by parameter
	 */
	@Override
	public void insert(Message Message) {
		logger.info("insert: " + Message);
		MessageDAO.insert(Message);
	}
	
	/**
	 * @param Message Message
	 * This method updates a Message passed by parameter
	 */
	@Override
	public void update(Message Message) {
		logger.info("update: " + Message);
		MessageDAO.update(Message);
	}
	
	/**
	 * @param Message role
	 * This method deletes a Message passed by parameter
	 */
	@Override
	public void delete(Message Message) {
		logger.info("delete: " + Message);
		MessageDAO.delete(Message);
	}

}
